<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <main id="app">
        <input type="text" v-model="person.name">
        {{person.name}}
    </main>
</body>
<script src="../vue.min.js"></script>
<script>
     let vue = new Vue({
        el: "#app",
        data() {
            return {
                person: {
                    name: "Hydra"
                }
            }
        },
        watch: {
            person: {
                // 深度侦听，用于监听对象内部的属性变化
                deep: true,
                // 立即监听：属性值初识改变的时候也会被监听
                immediate: true,
                handler(newVal,oldVal) {
                    console.log("person，newVal = ", newVal, ",oldVal = ", oldVal);
                }
            }
        }
    })
</script>
</html>